Skip to content

fix : corrected auth context API paths, action parameter, and user session fetch - #3

Open
tmdeveloper007 wants to merge 1 commit into
syedahmedkhaderi:mainfrom
tmdeveloper007:auth-context-fix
Open

fix : corrected auth context API paths, action parameter, and user session fetch#3
tmdeveloper007 wants to merge 1 commit into
syedahmedkhaderi:mainfrom
tmdeveloper007:auth-context-fix

Conversation

@tmdeveloper007

Copy link
Copy Markdown

Closes (upstream issues disabled — no issue created).

Summary of What Has Been Done:
Fixed three correctness bugs in app/contexts/AuthContext.js: (1) signup() and login() called the API at /auth/signup and /auth/login instead of the correct /api/auth path; (2) both functions omitted the required action and captchaToken parameters that the backend /api/auth route expects, causing all calls to fail with 'Invalid action' or 'Captcha token missing'; (3) the fetchUser() useEffect called a non-existent /auth/me endpoint instead of using Supabase's built-in getSession().

Changes Made:

  • app/contexts/AuthContext.js: fix API path to /api/auth, add action and captchaToken to signup/login payloads, replace /auth/me fetch with supabase.auth.getSession()

Impact it Made:

  • signup and login methods now make valid API calls that the backend can process
  • User session is correctly restored on page reload via Supabase auth state
  • Added backward compatibility with empty NEXT_PUBLIC_API_URL fallback

Note: Please assign this PR to the tmdeveloper007 account.

…user fetch

- Change API base to use empty string fallback so relative /api/auth paths work in browser
- Fix signup and login to call /api/auth (was /auth/signup and /auth/login — wrong paths)
- Add action parameter ('signup'/'login') required by backend API route
- Add captchaToken parameter to signup and login calls
- Replace non-existent /auth/me fetch with supabase.auth.getSession() for user session restore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant